﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Li.DingTalk.Model.Contacts
{
    /// <summary>
    ///   消息会话处理类  handel
    /// </summary>
    public class chatHD
    {
        /// <summary>
        /// 创建会话
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="scs">创建会话信息的结构体</param>
        /// <returns></returns>
        public static sessioncreation Createconversation(string access_token, sessioncreationstructural scs)
        {
            var path = string.Format("https://oapi.dingtalk.com/chat/create?access_token={0}", access_token);
            var StrJson= Newtonsoft.Json.JsonConvert.SerializeObject(scs);
            var Create= RequestHelper.Post(path, StrJson);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<sessioncreation>(Create);
        }

        /// <summary>
        /// 修改会话
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="mss">修改会话信息的结构体</param>
        /// <returns></returns>
        public static ResultPackage Modifyconversation(string access_token, modifysessionstructural mss)
        {
            var path = string.Format("https://oapi.dingtalk.com/chat/update?access_token={0}", access_token);
            var StrJson = Newtonsoft.Json.JsonConvert.SerializeObject(mss);
            var Update = RequestHelper.Post(path, StrJson);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<ResultPackage>(Update);
        }

        /// <summary>
        /// 获取会话信息
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="chatid">群会话的id</param>
        /// <returns></returns>
        public static obtainsession Obtainconversation(string access_token, string chatid)
        {
            var path = string.Format("https://oapi.dingtalk.com/chat/get?access_token={0}&chatid={1}", access_token, chatid);
            string resultJson = RequestHelper.Get(path);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<obtainsession>(resultJson);
        }

        #region 发送群消息
        /// <summary>
        /// 卡片消息无Action样式
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="nas">无Action样式的结构体</param>
        /// <returns></returns>
        public static ResultPackage Noaction(string access_token, noactionstructural nas)
        {
            var path = string.Format("https://oapi.dingtalk.com/chat/send?access_token={0}", access_token);
            var StrJson = Newtonsoft.Json.JsonConvert.SerializeObject(nas);
            var noaction = RequestHelper.Post(path, StrJson);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<ResultPackage>(noaction);
        }

        /// <summary>
        /// ActionCard消息整体跳转ActionCard样式
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="oas">单一Action样式的结构体</param>
        /// <returns></returns>
        public static ResultPackage Oneaction(string access_token, oneactionstructural oas)
        {
            var path = string.Format("https://oapi.dingtalk.com/chat/send?access_token={0}", access_token);
            var StrJson = Newtonsoft.Json.JsonConvert.SerializeObject(oas);
            var oneaction = RequestHelper.Post(path, StrJson);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<ResultPackage>(oneaction);
        }

        /// <summary>
        /// ActionCard消息独立跳转ActionCard样式
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="oas">多Action样式的结构体</param>
        /// <returns></returns>
        public static ResultPackage Manyaction(string access_token, manyactionstructural mas)
        {
            var path = string.Format("https://oapi.dingtalk.com/chat/send?access_token={0}", access_token);
            var StrJson = Newtonsoft.Json.JsonConvert.SerializeObject(mas);
            var oneaction = RequestHelper.Post(path, StrJson);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<ResultPackage>(oneaction);
        }

        /// <summary>
        /// 发送text消息
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="tms">text样式的结构体</param>
        /// <returns></returns>
        public static ResultPackage Textmessage(string access_token, textmessagestructural tms)
        {
            var path = string.Format("https://oapi.dingtalk.com/chat/send?access_token={0}", access_token);
            var StrJson = Newtonsoft.Json.JsonConvert.SerializeObject(tms);
            var sendtext = RequestHelper.Post(path, StrJson);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<ResultPackage>(sendtext);
        }

        /// <summary>
        /// 发送image消息
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="ims">imgme样式的结构体</param>
        /// <returns></returns>
        public static ResultPackage Imgmessage(string access_token, imgmessagestructural ims)
        {
            var path = string.Format("https://oapi.dingtalk.com/chat/send?access_token={0}", access_token);
            var StrJson = Newtonsoft.Json.JsonConvert.SerializeObject(ims);
            var sendimg = RequestHelper.Post(path, StrJson);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<ResultPackage>(sendimg);
        }

        /// <summary>
        /// 发送voice消息
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="vms">voice样式的结构体</param>
        /// <returns></returns>
        public static ResultPackage Voicemessage(string access_token, voicemessagestructural vms)
        {
            var path = string.Format("https://oapi.dingtalk.com/chat/send?access_token={0}", access_token);
            var StrJson = Newtonsoft.Json.JsonConvert.SerializeObject(vms);
            var sendvoice = RequestHelper.Post(path, StrJson);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<ResultPackage>(sendvoice);
        }

        /// <summary>
        /// 发送file消息
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="fms">file样式的结构体</param>
        /// <returns></returns>
        public static ResultPackage Filemessage(string access_token, filemessagestructural fms)
        {
            var path = string.Format("https://oapi.dingtalk.com/chat/send?access_token={0}", access_token);
            var StrJson = Newtonsoft.Json.JsonConvert.SerializeObject(fms);
            var sendfile = RequestHelper.Post(path, StrJson);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<ResultPackage>(sendfile);
        }

        /// <summary>
        /// 发送link消息
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="lms">link样式的结构体</param>
        /// <returns></returns>
        public static ResultPackage Linkmessage(string access_token, linkmessagestructural lms)
        {
            var path = string.Format("https://oapi.dingtalk.com/chat/send?access_token={0}", access_token);
            var StrJson = Newtonsoft.Json.JsonConvert.SerializeObject(lms);
            var sendlink = RequestHelper.Post(path, StrJson);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<ResultPackage>(sendlink);
        }

        /// <summary>
        /// 发送OA消息
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="oms">OA样式的结构体</param>
        /// <returns></returns>
        public static ResultPackage OAmessage(string access_token, oamessagestructural oms)
        {
            var path = string.Format("https://oapi.dingtalk.com/chat/send?access_token={0}", access_token);
            var StrJson = Newtonsoft.Json.JsonConvert.SerializeObject(oms);
            var sendoa = RequestHelper.Post(path, StrJson);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<ResultPackage>(sendoa);
        }

        /// <summary>
        /// 发送markdown消息
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="mdm">markdown样式的结构体</param>
        /// <returns></returns>
        public static ResultPackage Markdownmessage(string access_token, markdownmessagestructural mdm)
        {
            var path = string.Format("https://oapi.dingtalk.com/chat/send?access_token={0}", access_token);
            var StrJson = Newtonsoft.Json.JsonConvert.SerializeObject(mdm);
            var sendmarkdown = RequestHelper.Post(path, StrJson);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<ResultPackage>(sendmarkdown);
        }

        /// <summary>
        /// 发送普通消息
        /// </summary>
        /// <param name="access_token"></param>
        /// <param name="scs">发送普通消息样式的结构体</param>
        /// <returns></returns>
        public static sendconversation Sendconversationmessage(string access_token, sendconversationstructural scs)
        {
            var path = string.Format("https://oapi.dingtalk.com/chat/send?access_token={0}", access_token);
            var StrJson = Newtonsoft.Json.JsonConvert.SerializeObject(scs);
            var sendmessage = RequestHelper.Post(path, StrJson);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<sendconversation>(sendmessage);
        }


        #endregion 

        #region 会话信息
        /// <summary>
        /// 创建会话消息的结构体
        /// </summary>
        public class sessioncreationstructural
        {
            /// <summary>
            /// 群名称。长度限制为1~20个字符
            /// </summary>
            public string name
            {
                get;
                set;
            }
            /// <summary>
            /// 群主userId，员工唯一标识ID；必须为该会话useridlist的成员之一
            /// </summary>
            public string owner
            {
                get;
                set;
            }
            /// <summary>
            /// 群成员列表，每次最多操作40人，群人数上限为1000
            /// </summary>
            public string[] useridlist
            {
                get;
                set;
            }
            /// <summary>
            /// 新成员是否可查看聊天历史消息（新成员入群是否可查看最近100条聊天记录），0代表否，1代表是，不传默认为否
            /// </summary>
            public int showHistoryType
            {
                get;
                set;
            }
        }

        /// <summary>
        /// 创建会话信息
        /// </summary>
        public class sessioncreation : ResultPackage
        {
            /// <summary>
            /// 群会话的id
            /// </summary>
            public string chatid
            {
                get; set;
            }
        }

        /// <summary>
        /// 修改会话消息的结构体
        /// </summary>
        public class modifysessionstructural
        {
            /// <summary>
            /// 群会话的id
            /// </summary>
            public string chatid
            {
                get;
                set;
            }
            /// <summary>
            /// 群名称。长度限制为1~20个字符，不传则不修改
            /// </summary>
            public string name
            {
                get;
                set;
            }
            /// <summary>
            /// 群主userId，员工唯一标识ID；必须为该会话成员之一；不传则不修改
            /// </summary>
            public string owner
            {
                get;
                set;
            }
            /// <summary>
            /// 添加成员列表，每次最多操作40人，群人数上限为1000
            /// </summary>
            public string[] add_useridlist
            {
                get;
                set;
            }
            /// <summary>
            /// 删除成员列表，每次最多操作40人，群人数上限为1000
            /// </summary>
            public string[] del_useridlist
            {
                get;
                set;
            }
        }

        /// <summary>
        /// 获取群会话消息
        /// </summary>
        public class obtainsession : ResultPackage
        {
            /// <summary>
            /// 群会话信息
            /// </summary>
            public sessionmessage chat_info
            {
                get;
                set;
            }
        }

        /// <summary>
        /// 获取群会话信息
        /// </summary>
        public class sessionmessage
        {
            /// <summary>
            /// 群名称
            /// </summary>
            public string name
            {
                get;
                set;
            }
            /// <summary>
            /// 群主userid
            /// </summary>
            public string owner
            {
                get;
                set;
            }
            /// <summary>
            /// 群成员userId列表
            /// </summary>
            public string[] useridlist
            {
                get;
                set;
            }
        }

        /// <summary>
        /// 发送群消息，卡片消息无Action样式的结构体
        /// </summary>
        public class noactionstructural : ResultPackage
        {
            /// <summary>
            /// 群会话的id
            /// </summary>
            public string chatid
            {
                get;
                set;
            }

            /// <summary>
            /// 消息类型，此时固定为：action_card
            /// </summary>
            public string msgtype
            {
                get;
                set;
            }

            /// <summary>
            /// 消息体类型
            /// </summary>
            public nocardmessage action_card
            {
                get;
                set;
            }
        }

        /// <summary>
        /// 发送群消息卡片消息无Action样式消息体
        /// </summary>
        public class nocardmessage
        {
            /// <summary>
            /// 透出到会话列表和通知的文案
            /// </summary>
            public string title
            {
                get;
                set;
            }
            /// <summary>
            /// 消息内容，支持markdown，语法参考标准markdown语法。图片举例：![alt text](mediaId)
            /// </summary>
            public string markdown
            {
                get;
                set;
            }
            /// <summary>
            /// 可选，微应用agentid。默认在角标处显示企业的名称和图标，如果传入agentid则在角标处显示微应用的名称和图标
            /// </summary>
            public string agentid
            {
                get;
                set;
            }
        }

        /// <summary>
        /// 发送群消息，整体跳转ActionCard样式结构体
        /// </summary>
        public class oneactionstructural : ResultPackage
        {
            /// <summary>
            /// 群会话的id
            /// </summary>
            public string chatid
            {
                get;
                set;
            }
            /// <summary>
            /// 消息类型，此时固定为：action_card
            /// </summary>
            public string msgtype
            {
                get;
                set;
            }
            /// <summary>
            /// action_card消息体格式
            /// </summary>
            public onecardmessage action_card
            {
                get;
                set;
            }
        }

        /// <summary>
        /// ActionCard消息，整体跳转ActionCard样式消息体
        /// </summary>
        public class onecardmessage
        {
            /// <summary>
            /// 透出到会话列表和通知的文案
            /// </summary>
            public string title
            {
                get;
                set;
            }
            /// <summary>
            /// 消息内容，支持markdown，语法参考标准markdown语法。图片举例：![alt text](mediaId)
            /// </summary>
            public string markdown
            {
                get;
                set;
            }
            /// <summary>
            /// 使用单一Action样式时的标题，必须与single_url同时设置
            /// </summary>
            public string single_title
            {
                get;
                set;
            }
            /// <summary>
            /// 使用单一Action样式时的链接url，必须与single_title同时设置
            /// </summary>
            public string single_url
            {
                get;
                set;
            }
            /// <summary>
            /// 可选，微应用agentid。默认在角标处显示企业的名称和图标，如果传入agentid则在角标处显示微应用的名称和图标
            /// </summary>
            public string agentid
            {
                get;
                set;
            }
        }

        /// <summary>
        /// ActionCard消息，独立跳转ActionCard样式结构体
        /// </summary>
        public class manyactionstructural : ResultPackage
        {
            /// <summary>
            /// 群会话的id
            /// </summary>
            public string chatid
            {
                get;
                set;
            }
            /// <summary>
            /// 消息类型，此时固定为：action_card
            /// </summary>
            public string msgtype
            {
                get;
                set;
            }
            /// <summary>
            /// action_card消息体格式
            /// </summary>
            public manycardmessage action_card
            {
                get;
                set;
            }
        }

        /// <summary>
        /// ActionCard消息，独立跳转ActionCard样式消息体
        /// </summary>
        public class manycardmessage
        {
            /// <summary>
            /// 透出到会话列表和通知的文案
            /// </summary>
            public string title
            {
                get;
                set;
            }
            /// <summary>
            /// 消息内容，支持markdown，语法参考标准markdown语法。图片举例：![alt text](mediaId)
            /// </summary>
            public string markdown
            {
                get;
                set;
            }
            /// <summary>
            /// 使用多Action样式时的按钮排列方式，竖直排列(0)，横向排列(1)；必须与btn_json_list同时设置
            /// </summary>
            public string btn_orientation
            {
                get;
                set;
            }
            /// <summary>
            /// 使用多Action样式时的按钮列表；必须与btn_orientation同时设置
            /// </summary>
            public string[] btn_json_list
            {
                get;
                set;
            }
            /// <summary>
            /// 可选，微应用agentid。默认在角标处显示企业的名称和图标，如果传入agentid则在角标处显示微应用的名称和图标
            /// </summary>
            public string agentid
            {
                get;
                set;
            }
        }

        /// <summary>
        /// 使用多Action样式时的按钮列表
        /// </summary>
        public class manycardmessagebtn
        {
            /// <summary>
            /// 使用多Action样式时的按钮的标题
            /// </summary>
            public string title
            {
                get;
                set;
            }
            /// <summary>
            /// 使用多Action样式时的按钮的链接url
            /// </summary>
            public string action_url
            {
                get;
                set;
            }
        }

        /// <summary>
        /// text消息内容
        /// </summary>
        public class textmessagestructural : ResultPackage
        {
            /// <summary>
            /// 群会话的id
            /// </summary>
            public string chatid
            {
                get;
                set;
            }
            /// <summary>
            /// 消息类型，此时固定为：text
            /// </summary>
            public string msgtype
            {
                get;
                set;
            }
            /// <summary>
            /// text消息体格式
            /// </summary>
            public textmessages text
            {
                get;
                set;
            }
        }

        /// <summary>
        /// text消息内容
        /// </summary>
        public class textmessages
        {
            /// <summary>
            /// 消息内容
            /// </summary>
            public string content
            {
                get;
                set;
            }
        }

        /// <summary>
        /// img消息内容
        /// </summary>
        public class imgmessagestructural : ResultPackage
        {
            /// <summary>
            /// 群会话的id
            /// </summary>
            public string chatid
            {
                get;
                set;
            }
            /// <summary>
            /// 消息类型，此时固定为：image
            /// </summary>
            public string msgtype
            {
                get;
                set;
            }
            /// <summary>
            /// image消息体格式
            /// </summary>
            public imagemessage image
            {
                get;
                set;
            }
        }

        /// <summary>
        /// image消息内容
        /// </summary>
        public class imagemessage
        {
            /// <summary>
            /// 图片媒体文件id，可以调用上传媒体文件接口获取。建议宽600像素 x 400像素，宽高比3：2
            /// </summary>
            public string media_id
            {
                get;
                set;
            }
        }

        /// <summary>
        /// voice消息内容
        /// </summary>
        public class voicemessagestructural : ResultPackage
        {
            /// <summary>
            /// 群会话的id
            /// </summary>
            public string chatid
            {
                get;
                set;
            }
            /// <summary>
            /// 消息类型，此时固定为：voice
            /// </summary>
            public string msgtype
            {
                get;
                set;
            }
            /// <summary>
            /// voice消息体格式
            /// </summary>
            public voicemessages voice
            {
                get;
                set;
            }
        }

        /// <summary>
        /// voice消息内容
        /// </summary>
        public class voicemessages
        {
            /// <summary>
            /// 语音媒体文件id，可以调用上传媒体文件接口获取。2MB，播放长度不超过60s，AMR格式
            /// </summary>
            public string media_id
            {
                get;
                set;
            }

            /// <summary>
            /// 正整数，小于60，表示音频时长
            /// </summary>
            public string duration
            {
                get;
                set;
            }
        }

        /// <summary>
        /// file消息内容
        /// </summary>
        public class filemessagestructural : ResultPackage
        {
            /// <summary>
            /// 群会话的id
            /// </summary>
            public string chatid
            {
                get;
                set;
            }
            /// <summary>
            /// 消息类型，此时固定为：file
            /// </summary>
            public string msgtype
            {
                get;
                set;
            }
            /// <summary>
            /// file消息体格式
            /// </summary>
            public filesmessage file
            {
                get;
                set;
            }
        }

        /// <summary>
        /// file消息内容
        /// </summary>
        public class filesmessage
        {
            /// <summary>
            /// 媒体文件id，可以调用上传媒体文件接口获取。10MB
            /// </summary>
            public string media_id
            {
                get;
                set;
            }
        }

        /// <summary>
        /// link消息内容
        /// </summary>
        public class linkmessagestructural : ResultPackage
        {
            /// <summary>
            /// 群会话的id
            /// </summary>
            public string chatid
            {
                get;
                set;
            }
            /// <summary>
            /// 消息类型，此时固定为：link
            /// </summary>
            public string msgtype
            {
                get;
                set;
            }
            /// <summary>
            /// link消息体格式
            /// </summary>
            public linkmessages link
            {
                get;
                set;
            }
        }

        /// <summary>
        /// link消息内容
        /// </summary>
        public class linkmessages
        {
            /// <summary>
            /// 消息标题
            /// </summary>
            public string title
            {
                get;
                set;
            }
            /// <summary>
            /// 消息描述
            /// </summary>
            public string text
            {
                get;
                set;
            }
            /// <summary>
            /// 图片媒体文件id，可以调用上传媒体文件接口获取
            /// </summary>
            public string picUrl
            {
                get;
                set;
            }
            /// <summary>
            /// 消息点击链接地址
            /// </summary>
            public string messageUrl
            {
                get;
                set;
            }
        }

        /// <summary>
        /// OA消息内容
        /// </summary>
        public class oamessagestructural : ResultPackage
        {
            /// <summary>
            /// 群会话的id
            /// </summary>
            public string chatid
            {
                get;
                set;
            }
            /// <summary>
            /// 消息类型，此时固定为：oa
            /// </summary>
            public string msgtype
            {
                get;
                set;
            }

            /// <summary>
            /// OA消息体格式
            /// </summary>
            public oalist oa
            {
                get;
                set;
            }
        }

        /// <summary>
        /// OA消息体格式
        /// </summary>
        public class oalist
        {
            /// <summary>
            /// 客户端点击消息时跳转到的H5地址
            /// </summary>
            public string message_url
            {
                get;
                set;
            }

            /// <summary>
            /// PC端点击消息时跳转到的URL地址
            /// </summary>
            public string pc_message_url
            {
                get;
                set;
            }

            /// <summary>
            /// 消息头部内容
            /// </summary>
            public headmessage head
            {
                get;
                set;
            }

            /// <summary>
            /// 消息体
            /// </summary>
            public bodymessage body
            {
                get;
                set;
            }

        }

        /// <summary>
        /// 消息头部内容
        /// </summary>
        public class headmessage
        {
            /// <summary>
            /// 消息头部的背景颜色。长度限制为8个英文字符，其中前2为表示透明度，后6位表示颜色值。不要添加0x
            /// </summary>
            public string bgcolor
            {
                get;
                set;
            }

            /// <summary>
            /// 消息的头部标题（仅适用于发送普通场景），长度限制为最多10个字符
            /// </summary>
            public string text
            {
                get;
                set;
            }
        }

        /// <summary>
        /// OA内容的消息体
        /// </summary>
        public class bodymessage
        {
            /// <summary>
            /// 消息体的标题
            /// </summary>
            public string title
            {
                get;
                set;
            }

            /// <summary>
            /// 消息体的表单，最多显示6个，超过会被隐藏
            /// </summary>
            public formmessage[] form
            {
                get;
                set;
            }

            /// <summary>
            /// 单行富文本信息
            /// </summary>
            public richmessage rich
            {
                get;
                set;
            }

            /// <summary>
            /// 消息体的内容，最多显示3行
            /// </summary>
            public string content
            {
                get;
                set;
            }

            /// <summary>
            /// 消息体中的图片media_id
            /// </summary>
            public string image
            {
                get;
                set;
            }

            /// <summary>
            /// 自定义的附件数目。此数字仅供显示，钉钉不作验证
            /// </summary>
            public string file_count
            {
                get;
                set;
            }

            /// <summary>
            /// 自定义的作者名字
            /// </summary>
            public string author
            {
                get;
                set;
            }

        }

        /// <summary>
        /// 消息体的表单，最多显示6个，超过会被隐藏
        /// </summary>
        public class formmessage
        {
            /// <summary>
            /// 消息体的关键字
            /// </summary>
            public string key
            {
                get;
                set;
            }

            /// <summary>
            /// 消息体的关键字对应的值
            /// </summary>
            public string value
            {
                get;
                set;
            }
        }

        /// <summary>
        /// 单行富文本信息内容
        /// </summary>
        public class richmessage
        {
            /// <summary>
            /// 单行富文本信息的数目
            /// </summary>
            public string num
            {
                get;
                set;
            }

            /// <summary>
            /// 单行富文本信息的单位
            /// </summary>
            public string unit
            {
                get;
                set;
            }
        }

        /// <summary>
        /// markdown消息内容
        /// </summary>
        public class markdownmessagestructural : ResultPackage
        {
            /// <summary>
            /// 群会话的id
            /// </summary>
            public string chatid
            {
                get;
                set;
            }
            /// <summary>
            /// 消息类型，此时固定为：markdown
            /// </summary>
            public string msgtype
            {
                get;
                set;
            }

            /// <summary>
            /// markdown消息体格式
            /// </summary>
            public markdowns markdown
            {
                get;
                set;
            }
        }

        /// <summary>
        /// markdown消息体格式
        /// </summary>
        public class markdowns
        {
            /// <summary>
            /// 首屏会话透出的展示内容
            /// </summary>
            public string title
            {
                get;
                set;
            }

            /// <summary>
            /// markdown格式的消息
            /// </summary>
            public string text
            {
                get;
                set;
            }
        }

        /// <summary>
        /// 发送普通消息的结构体
        /// </summary>
        public class sendconversationstructural
        {
            /// <summary>
            /// 消息发送者员工ID
            /// </summary>
            public string sender
            {
                get;
                set;
            }
            /// <summary>
            /// 群消息或者个人聊天会话Id，(通过JSAPI之pickConversation接口唤起联系人界面选择之后即可拿到会话ID，之后您可以使用获取到的cid调用此接口）
            /// </summary>
            public string cid
            {
                get;
                set;
            }

            /// <summary>
            /// 消息类型，此时固定为：text
            /// </summary>
            public string msgtype
            {
                get;
                set;
            }

            /// <summary>
            /// 发送的消息内容
            /// </summary>
            public sendtextmessage text
            {
                get;
                set;
            }
        }

        /// <summary>
        /// 发送普通消息的消息内容
        /// </summary>
        public class sendtextmessage
        {
            /// <summary>
            /// 消息内容
            /// </summary>
            public string content
            {
                get;
                set;
            }
        }

        /// <summary>
        /// 发送普通消息
        /// </summary>
        public class sendconversation : ResultPackage
        {
            /// <summary>
            /// 如果是群，返回跟发送者同一家企业的一组工号；如果是个人聊天，只返回发送者同一家企业的一个工号；不在同一家企业，发送失败
            /// </summary>
            public string receiver
            {
                get;
                set;
            }
        }

        #endregion 
    }


}
